public class Demo6 {
	public static int count=0;
	public static void main(String[] args) throws InterruptedException {
		Object locker =new Object();
		Thread t=new Thread(()->{
			synchronized (locker) {
				for (int i =0;i<50000;i++) {
					count++;
				}
			}
		});
		Thread  t1=new Thread(()->{
			synchronized (locker) {
				for (int i =0;i<50000;i++) {
					count++;
				}
			}
		});
		t.start();
		t1.start();
		//如果没有这两个东西，count还没有来得及开始自增，就已经打印结束了，结果可能是0；
		t.join();
		t1.join();
		System.out.println(count);
	}
}
